package aidturith.ihm.action.key;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import aidturith.ihm.panel.proto.TablePanel;

public class EnterAction extends AbstractAction {

	private static final long serialVersionUID = 1L;

	private TablePanel panel;

	public EnterAction(TablePanel panel) {
		this.panel = panel;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		int rows = panel.getTable().getRowCount();
		int current_row = panel.getTable().getSelectedRow();
		if(current_row < (rows-1))
			panel.selectRow(current_row+1);
		else if(panel.isEditing())
			panel.addRow("");
	}

}
